package com.zw.cc.common;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 自定义静态资源目录
 */
@Configuration
@EnableWebMvc
public class MyWebMvcConfigurerAdapter implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        映射 URL /resources/  到目录 /myResource/
        registry.addResourceHandler("/resources/**")
                .addResourceLocations("classpath:/myResource/")
                .setCachePeriod(31556926);
//        映射 URL /mypath/  到目录 /myResource/
        registry.addResourceHandler("/mypath/**")
                .addResourceLocations("classpath:/myResource/")
                .setCachePeriod(31556926);
    }
}
